<template>
	<view class="index" :style="{'--color':vuex_config.themeColor1}">
		<u-field v-model="name" label="报名活动" input-align='right' :clearable="false" disabled="true" @click="open" placeholder="请选择报名活动">
		</u-field>
		<u-field v-model="dataForm.score" label="分数" input-align='right' :clearable="false" placeholder="请填写分数">
		</u-field>
		<u-field v-model="dataForm.remarks" type='textarea' label="备注" input-align='right' :clearable="false" placeholder="请填写备注">
		</u-field>
		<view class="btn-box">
			<view class="btn" @click="onSubmit">提交</view>
		</view>
		<u-picker mode="selector" v-model="show"  :range="dataList" range-key='name' :default-selector="[0]" @confirm='onConfirm'></u-picker>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				show:false,
				dataList:[],
				dataForm:{
					info_id:'',
					score:'',
					remarks:''
				},
				name:''
			}
		},
		onLoad(){
			this.initPage()
		},
		methods:{
			initPage(){
				this.$adminPost('adminGetEnrollInfoList',{
					business_id:this.vuex_business.pk_id,
					page:1,
					page_size:99999,
					mechanism_id:this.vuex_adminuser.enroll_id,
					status:1
				}).then(res=>{
					this.dataList = res.data
				})
			},
			onConfirm(val){
				this.name = this.dataList[val[0]].name
				this.dataForm.info_id = this.dataList[val[0]].pk_id
			},
			open(){
				this.show = true
			},
			onSubmit(){
				this.$loading()
				this.$adminPost('UpdateEnrollScore',this.dataForm).then(res=>{
					if(res.data){
						this.$toast('修改成功')
					}else{
						this.$toast('修改失败')
					}
					this.$hide()
				}).catch(()=>{
					this.$toast('修改失败')
					this.$hide()
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.index {
		padding: 0 30rpx;
		.btn-box{
			width: 100%;
			height: 200rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			.btn{
				position: fixed;
				bottom: 0;
				width: 690rpx;
				height: 80rpx;
				background-color: var(--color);
				border-radius: 10rpx;
				color: #fff;
				display: flex;
				align-items: center;
				justify-content: center;
				margin-bottom: env(safe-area-inset-bottom);
			}
		}
	}
</style>
